package com.boss.salary.controller;

import com.boss.api.dto.ApiResultDTO;
import com.boss.common.base.BasicinfoBaseController;
import com.boss.salary.entity.VoucherGeneration;
import com.boss.salary.service.ISalaryBackLogService;
import com.boss.sys.ca.user.dto.UserDTO;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 张铭浩
 * 凭证生成Controller
 */
@RestSchema(schemaId = "VoucherGenerationExtController")
@RestController
@RequestMapping(value = "/VoucherGenerationExtController")
public class VoucherGenerationExtController extends BasicinfoBaseController {
    /**
     * 引入日志框架常量
     */
    private final static Logger logger = LoggerFactory.getLogger(AgencyInfoAuditController.class);

    @Autowired
    private ISalaryBackLogService iSalaryBackLogService;


    /**
     * 凭证生成 插入 新增
     * @param
     * @return
     */
    @PostMapping("/saveVoucherGeneration")
    public ApiResultDTO saveVoucherGeneration(@RequestHeader("X-Token") String tokenid) {
        try {
            UserDTO userDTO = getUser(tokenid);

            iSalaryBackLogService.saveSalaryBackLog(null,null,"paymentSuccess",userDTO.getProvince());
            return ApiResultDTO.success(null, "保存成功");
        } catch (Exception e) {
            logger.error("新增 单位信息表发生异常", e);
            return ApiResultDTO.error(ERROR_RSCODE, "新增 单位信息表发生异常");
        }
    }

}
